import {httpClient} from "@/core/http/httpClient";
import {ddVideoMatch} from "@/api/baseUrl";


/**
 * @typedef PageQuery
 * @property {number} pageNum
 * @property {number} pageSize
 * */
/**
 *@typedef UploadVideoParam
 *@property {number} userId
 *@property {string} nickName
 *@property {string} workName
 *@property {string} workDesc
 *@property {string} workVideoUrl
 */

/**
 * @author vidy3587@gmail.com
 * @param {UploadVideoParam} params
 * @return {Promise<BaseResponse>}
 * */
export const uploadVideo = (params) => {
    return httpClient.post(`/${ddVideoMatch}/activities/dd2021VideoMatch/uploadVideo`,params, {
        headers: {
            'Content-Type': 'application/json'
        },
        data: JSON.stringify(params)
    })
}


/**
 *@typedef VideoRankItem
 *@property {number} rank
 *@property {number} workNumber
 *@property {string} nickName
 *@property {number} ticketNum
 */

/**
 * @author vidy3587@gmail.com
 * @description 查询排行榜
 * @param {PageQuery} pageQuery
 * @return {Promise<BaseResponse<PageData<VideoRankItem>>>}
 */
export const getRankList = (pageQuery) => {
    return httpClient.post(`/${ddVideoMatch}/activities/dd2021VideoMatch/getRankList`, pageQuery)
}

/**
 *@typedef WorkInfoDetail
 *@property {number} userId
 *@property {number} workNumber
 *@property {string} workName
 *@property {string} workDesc
 *@property {string} workVideoUrl
 *@property {number} rank
 *@property {number} ticketNum
 */

/**
 * @author vidy3587@gmail.com
 * @description 查询作品详情
 * @param {string} queryParam
 * @return {Promise<BaseResponse<WorkInfoDetail>>}
 */
export const getWorkInfoByIdOrName = (queryParam) => {
    return httpClient.post(`/${ddVideoMatch}/activities/dd2021VideoMatch/getWorkInfoByIdOrName`, {queryParam})

}

/**
 *@typedef WorkInfo
 *@property {number} userId
 *@property {number} workNumber
 *@property {string} workName
 *@property {any} [workDesc]
 *@property {string} workVideoUrl
 *@property {number} rank
 *@property {number} ticketNum
 */

/**
 * @author vidy3587@gmail.com
 * @description 查询作品列表
 * @param {PageQuery} pageQuery
 * @return {Promise<BaseResponse<PageData<WorkInfo>>>}
 */
export const getWorkInfoList = (pageQuery) => {
    return httpClient.post(`/${ddVideoMatch}/activities/dd2021VideoMatch/getWorkList`, pageQuery)
}

/**
 * @description 作品审核状态枚举
 * @enum {number}
 * */
export const WorkStatusEnum = {
    "reviewing": 0,
    "success": 1,
    "rejected": 2,
    "notUpload": 9
}

/**
 * @typedef WorkStatus
 * @property {number} workNumber 审核通过为作品编号 否则为null
 * @property {WorkStatusEnum} workStatus 0-审核中 1-审核通过 2-审核未通过 9-未上传
 * @example {
    "workStatus": 1,//0-审核中 1-审核通过 2-审核未通过 9-未上传
    "workNumber": 1234//审核通过为作品编号 否则为null
  }
 */

/**
 * @description 获取作品状态
 * @author vidy3587@gmail.com
 * @param {string} userId
 * @return {Promise<BaseResponse<WorkStatus>>}
 */
export const getWorkInfoStatus = (userId) => {
    return httpClient.post(`/${ddVideoMatch}/activities/dd2021VideoMatch/getWorkStatus`, {userId})
}


/**
 * @author vidy3587@gmail.com
 * @description 短视频投票
 * @param {string} workNumber
 * @param {string} userId
 * @return {Promise<BaseResponse<any>>}
 */
export const giveTicket = ({workNumber, userId}) => {
    return httpClient.post(`/${ddVideoMatch}/activities/dd2021VideoMatch/giveTicket`, {workNumber, userId})
}